package orthoplanner.com.google.code.ui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import orthoplanner.com.google.code.eventhandlers.ImageRotationSliderHandler;
import orthoplanner.com.google.code.eventhandlers.RotationResetHandler;


public class RotationPanel extends JPanel {
	private static final long serialVersionUID = 2941981669032095605L;
	private JButton bRotationReset;
	private JSlider slRotation;

	public RotationPanel(ImageViewer imgViewer) {
		setFont( new Font("SansSerif", Font.BOLD, 12));
		setPreferredSize(new Dimension(200, 80));
		bRotationReset = new JButton("Reset");
		bRotationReset.setFont( new Font("SansSerif", Font.BOLD, 12));
		slRotation = new JSlider(SwingConstants.HORIZONTAL, 1, 1000, 500);
		
		bRotationReset.addMouseListener(new RotationResetHandler(slRotation));
		slRotation.addChangeListener(new ImageRotationSliderHandler(imgViewer));
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.anchor = GridBagConstraints.LAST_LINE_END;
		add(bRotationReset, gbc);
		gbc.gridy = 1;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		add(slRotation, gbc);
		setBorder(new TitledBorder("Rotation"));

	}

	public JButton getbRotationReset() {
		return bRotationReset;
	}

	public JSlider getSlRotation() {
		return slRotation;
	}

}
